
//
//  ExercieseSubjectiveCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/8.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "ExercieseQuestionSubjectiveCell.h"

@interface ExercieseQuestionSubjectiveCell ()
@property (nonatomic,strong)UILabel *titleLb;
@property (nonatomic,strong)UILabel *placeLb;
@end

@implementation ExercieseQuestionSubjectiveCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    self.titleLb = [[UILabel alloc]init];
//    self.titleLb.text = @"14. 用自己的话说说白居易一行游大林寺的行踪。";
    self.titleLb.textColor = RGBA(51, 51, 51, 1);
    self.titleLb.font = font(14);
    self.titleLb.numberOfLines = 0;
    [self.contentView addSubview:self.titleLb];
    
    self.placeLb = [[UILabel alloc]init];
    self.placeLb.text = @"本题仅支持线下作答，可在交卷后核对答案并查看解析";
    self.placeLb.textColor = RGBA(153, 153, 153, 1);
    self.placeLb.font = font(12);
    [self.contentView addSubview:self.placeLb];
    
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.contentView).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
    }];
    
    [self.placeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLb.mas_bottom).offset(8);
        make.left.right.mas_equalTo(self.titleLb);
        make.bottom.equalTo(self.contentView).offset(-16);
    }];
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"ExercieseQuestionSubjectiveCell";
    ExercieseQuestionSubjectiveCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[ExercieseQuestionSubjectiveCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (void)setModel:(ExercieseQuestionItemModel *)model{
    _model = model;
     

    [[HTMLHelper alloc]attributedTextFromHTML:model.title andCompleteBlock:^(NSMutableAttributedString *content) {
        self.titleLb.attributedText = content;
        if (self.updateTableViewFrame) {
            self.updateTableViewFrame();
        }
    }];
}
@end
